package com.gxuwz.eschool.fragment;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;

import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.gxuwz.eschool.BalanceActivity;
import com.gxuwz.eschool.BatheActivity;
import com.gxuwz.eschool.CardLossReportActivity;
import com.gxuwz.eschool.CardRechargeActivity;
import com.gxuwz.eschool.CardUnlockingActivity;
import com.gxuwz.eschool.ChangePasswordActivity;
import com.gxuwz.eschool.DetailedQueryActivity;
import com.gxuwz.eschool.NewAnnouncementActivity;
import com.gxuwz.eschool.PaymentActivity;
import com.gxuwz.eschool.R;
import com.gxuwz.eschool.SchoolIntroductionActivity;
import com.gxuwz.eschool.UtilityBillPaymentActivity;
import com.gxuwz.eschool.WaterRechargeActivity;
import com.gxuwz.eschool.WaterRecordActivity;

import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
//校园卡fragment
public class CardFragment extends Fragment {

    private ImageView imageView;
    private TextView tv_payment;
    private TextView tv_card_recharge;
    private TextView tv_detailed;
    private TextView tv_card_loss_report;
    private TextView tv_card_unlocking;
    private TextView tv_balance;
    private TextView tv_change_password;
    private TextView tv_scan;

    public CardFragment() {

    }


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        // Inflate the layout for this fragment
//        return inflater.inflate(R.layout.fragment_card, container, false);
        View rootView = inflater.inflate(R.layout.fragment_card, container, false);
        imageView = rootView.findViewById(R.id.iv_bdschool);
        loadRoundedImage();

        tv_payment = rootView.findViewById(R.id.tv_payment);
        tv_card_recharge = rootView.findViewById(R.id.tv_card_recharge);
        tv_detailed = rootView.findViewById(R.id.tv_detailed);
        tv_card_loss_report = rootView.findViewById(R.id.tv_card_loss_report);
        tv_card_unlocking = rootView.findViewById(R.id.tv_card_unlocking);
        tv_balance = rootView.findViewById(R.id.tv_balance);
        tv_change_password = rootView.findViewById(R.id.tv_change_password);
        tv_scan = rootView.findViewById(R.id.tv_scan);

        tv_payment.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(), PaymentActivity.class);
                startActivity(intent);
            }
        });


        tv_card_recharge.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(), CardRechargeActivity.class);
                startActivity(intent);
            }
        });

        tv_detailed.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(), DetailedQueryActivity.class);
                startActivity(intent);
            }
        });

        tv_card_loss_report.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(), CardLossReportActivity.class);
                startActivity(intent);
            }
        });
        tv_card_unlocking.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(), CardUnlockingActivity.class);
                startActivity(intent);
            }
        });


        tv_balance.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(), BalanceActivity.class);
                startActivity(intent);
            }
        });
        tv_change_password.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(), ChangePasswordActivity.class);
                startActivity(intent);
            }
        });
        tv_scan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                new AlertDialog.Builder(requireContext()) // 使用requireContext()或getContext()
                        .setTitle("提示")
                        .setMessage("该功能暂不可使用！")
                        .setPositiveButton("完成", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss(); // 关闭对话框
                            }
                        })
                        .show();
            }
        });


        return rootView;
    }
    //图片设置圆角
    private void loadRoundedImage() {
        Glide.with(this)
                .load(R.drawable.card_school)
                .apply(RequestOptions.bitmapTransform(new RoundedCorners(50))) // 设置圆角半径为100像素
                .into(imageView);


    }

}